import * as types from '../constants/ActionTypes';
import Request from '../utils/request';

/**
*收藏客户
*/
const fetchCollect = (id, collectStatus) => (dispatch) => {
  Request.post({
    url: `/dealer/users/mark/${id}?collect=${collectStatus}`,
    success: () => {
      dispatch(collect(1));
    },
    fail: () => {
      console.log('fail');
      dispatch(collect(0));
    },
    error: () => {
      console.log('error');
      dispatch(collect(0));
    },
  });
};

const collect = collectCode => ({
  type: types.SALE_COLLECT,
  collectCode,
});

export default fetchCollect;
